package as3.component.controls
{
	import flash.events.MouseEvent;

	public class TabButton extends ToggleButton
	{
		public function TabButton(labelValue:String="按钮")
		{
			super(labelValue);
		}
		
		override protected function initUI():void
		{
			super.initUI();
			_uiLibrary["upImage"] = "TabButton_upSkin";
			_uiLibrary["overImage"] = "TabButton_upSkin";
			_uiLibrary["downImage"] = "TabButton_upSkin";
			_uiLibrary["disabledImage"] = "TabButton_disabledSkin";
			
			_uiLibrary["selectUpImage"] = "TabButton_selectUpSkin";
			_uiLibrary["selectOverImage"] = "TabButton_selectUpSkin";
			_uiLibrary["selectDownImage"] = "TabButton_selectUpSkin";
			_uiLibrary["selectDisabledImage"] = "TabButton_disabledSkin";
			
			_upTextColor = _defaultSkin.tabBtnCssTabel.upTextColor || 0x000000;
			_overTextColor = _defaultSkin.tabBtnCssTabel.overTextColor || 0x000000;
			_downTextColor = _defaultSkin.tabBtnCssTabel.downTextColor || 0x000000;
			_enableTextColor = _defaultSkin.tabBtnCssTabel.enableTextColor || 0x666666;
			_fontBold = _defaultSkin.tabBtnCssTabel.fontBold || false;
			_fontSize = _defaultSkin.tabBtnCssTabel.fontSize || 12;
			
			_upSelectTextColor = _defaultSkin.tabBtnCssTabel.upSelectTextColor || 0x000000;
			_overSelectTextColor = _defaultSkin.tabBtnCssTabel.overSelectTextColor || 0x000000;
			_downSelectTextColor = _defaultSkin.tabBtnCssTabel.downSelectTextColor || 0x000000;
			_enableSelectTextColor = _defaultSkin.tabBtnCssTabel.enableSelectTextColor || 0x666666;
			_fontSelectBold = _defaultSkin.tabBtnCssTabel.fontSelectBold || false;
			_fontSelectSize = _defaultSkin.tabBtnCssTabel.fontSelectSize || 12;
			
			_minWidth = 60;
		}
		
		//仅在TabBar中使用
		public function unSelected():void
		{
			if (_selected == false) return;
			_selected = false;
			updateEnable();
		}
		
		override protected function $onMouseUpHandler(evt:MouseEvent):void
		{
			if (selected) return;
			super.$onMouseUpHandler(evt);
			_textField.color = selected ? _overSelectTextColor : _overTextColor;
			_textField.fontSize = selected ? _fontSelectSize : _fontSize;
			_textField.bold = selected ? _fontSelectBold : _fontBold;
			
		}
	}
}